home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7256 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: pegasus.montclair.edu!harmon
  2. From: harmon@pegasus.montclair.edu (Derek Harmon)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What the heck is ...?
  5. Date: 12 Feb 1996 17:43:44 -0500
  6. Organization: Montclair State University
  7. Message-ID: <harmon.824164401@pegasus.montclair.edu>
  8. References: <sconi-1102961642580001@ip-24.newportnet.net> <4fmlro$nfg_001@pr.mcs.net>
  9. NNTP-Posting-Host: pegasus.montclair.edu
  10. X-Newsreader: NN version 6.5.0 #68 (NOV)
  11.  
  12. mdp@mika-sys.com (Michael D. Perry) writes:
  13. >   sconi@superstore.com (Chris Tiee "Chochoni Boboni") wrote:
  14. >>Here's something all the books love to avoid: The use of ... in 
  15. >function
  16. >>declarations. For example, one book says that the prototype of 
  17. >printf() is
  18. >>
  19. >>int printf(const char *fmt_string, ...);
  20. >>
  21.  
  22. >What the ellipses mean is that it is a repeatable item.  In the 
  23. >case that you cite it takes the place of saying that all of the 
  24. >following statements are valid:
  25.   
  26.    "Repeatable" is incorrect.  The following statement will never compile,
  27.  
  28. >printf("%d, ..., %d", 1 ... 7);
  29.  
  30.    The first reason it won't compile is it isn't C, the second reason it
  31. won't compile is because it is impossible for a compiler to have any grasp
  32. of what lies between the %d's and the 1 thru 7.
  33.  
  34.    The ellipsis is used in function headings and prototypes to signify that
  35. a variable number (0 or greater) of arguments of nondescript type follow.
  36. This is what gives printf() and sscanf() the power they have, since it is
  37. the fmt_string that specifies how many arguments printf() should expect.
  38. Using the functions in the <stdarg.h> library, it is possible to write
  39. C functions which can handle a variable number of arguments, as long as
  40. the function can tell how many arguments it should expect.
  41.  
  42.                                                           -- Stone
  43. --
  44. # Derek Harmon (aka Stonelight)    harmon@pegasus.montclair.edu
  45. # - Computer Science Undergrad, Montclair State University, NJ
  46. # - My views are my own, nobody else is this creative.  3;)>
  47. ... Where there's a will, there's an inheritance tax.
  48.